import React from 'react';
import { connect } from 'dva';
import TodoList from '../components/TodoList'


const Todos = ({ dispatch, todos }) => {
    function handleDelete(id) {
        console.log('handleDelete', { id })
        // 调用*deleteAfter1Second
        dispatch({ type: 'todos/deleteAfter1Second', payload: id })
    }
    return (
        <div>
            <h2>Todos</h2>
            <TodoList onDelete={handleDelete} todos={todos} />
        </div>
    )
}

export default connect(({ todos }) => ({ todos }))(Todos)